package com.qidian.mes.cal.controller;

import com.qidian.mes.cal.service.TeamService;
import com.qidian.mes.pojo.Team;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/cal")
public class TeamController {
    @Autowired
    TeamService teamService;
    /*
     * 分页查询
     */
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = " 10") int limit, Team team) {
        return teamService.list(page,limit,team);
    }
    //添加班组数据
    @PostMapping("/save")
    public MESResult save(@RequestBody Team team) {
        return teamService.save(team);
    }

    @GetMapping("/selectByTeamId")
    //根据id查询班组数据
    public MESResult selectByTeamId(Long teamId) {
        return teamService.selectByTeamId(teamId);
    }

    @PutMapping("/update")
    //更改班组数据
    public MESResult update(@RequestBody Team team) {
        return teamService.update(team);
    }

    @DeleteMapping("/deleteById")
    //删除班组,同时删除班组与用户的关系
    public MESResult deleteById(String[] teamCodes) {
        return teamService.deleteById(teamCodes);
    }

    @GetMapping("/getList")
    //查询全部班组数据
    public MESResult getList() {
        return teamService.getList();
    }

    @GetMapping("/selectByTeamCode")
    //根据班组编码查班组信息
    public MESResult selectByTeamCode(String teamCode) {
        return teamService.selectByTeamCode(teamCode);
    }
}
